package com.liug.droidsmall2.fragment;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.liug.droidsmall2.R;
import com.liug.droidsmall2.activity.VrActivity;
import com.liug.droidsmall2.activity.dfsfdsd;
import com.liug.droidsmall2.base.BaseFragment;
import com.yanzhenjie.album.Album;
//import com.yanzhenjie.album.Album;

/**
 * 论坛页面
 * Created by LG on 2018/7/31.
 */

public class StudyFragment extends BaseFragment {

    private static final int ACTIVITY_ALBUM = 999;
    public static final int ACTIVITY_CAMREA = 666;
    private GridView lv_cc;

    @Override
    public void initData(Bundle savedInstanceState, Context context) {

    }

    @Override
    public void initView(View view, Context context) {

/*        lv_cc = (GridView) view.findViewById(R.id.lv_cc);

        final LinearLayout top_menu = (LinearLayout) view.findViewById(R.id.top_menu);

        for (int i = 0; i < top_menu.getChildCount(); i++) {
            final TextView tv = (TextView) top_menu.getChildAt(i);
            final int finalI = i;
            tv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    for (int j = 0; j < top_menu.getChildCount(); j++) {
                        final TextView tv1 = (TextView) top_menu.getChildAt(j);
                        if (finalI == j) {
                            tv1.setBackgroundResource(R.drawable.catory_top_bg_sele);
                            tv1.setTextColor(Color.WHITE);
                        } else {
                            tv1.setBackgroundResource(R.drawable.catory_top_bg_dissele);
                            tv1.setTextColor(Color.BLACK);
                        }
                    }
                }
            });
            top_menu.getChildAt(0).callOnClick();
        }


        lv_cc.setAdapter(new BaseAdapter() {
            @Override
            public int getCount() {
                return 112;
            }

            @Override
            public Object getItem(int i) {
                return null;
            }

            @Override
            public long getItemId(int i) {
                return 0;
            }

            @Override
            public View getView(final int i, View view, ViewGroup viewGroup) {

                final View inflate = View.inflate(viewGroup.getContext(), R.layout.catory_fr_item, null);

                ImageView img = (ImageView) inflate.findViewById(R.id.img);
                TextView tv = (TextView) inflate.findViewById(R.id.tv);

                if (i % 2 == 0) {
                    Glide.with(getActivity()).load(R.mipmap.gif1)//.transform(new GlideRoundTransform(getActivity(), 80))
                            .into(img);
                } else {
                    Glide.with(getActivity()).load(R.mipmap.gif3)//.transform(new GlideRoundTransform(getActivity(), 80))
                            .into(img);
                }

                if (i == 0) {
                    tv.setText("Java基础");
                } else {
                    tv.setText("介绍IDE");
                }


                inflate.setOnClickListener(new View.OnClickListener() {


                    @Override
                    public void onClick(View view) {
//                        ToStartActivity(dfsfdsd.class);

                        if (i == 0) {
                            ToStartActivity(dfsfdsd.class);
                        } else if (i == 1) {
                            Album.camera(getActivity())
                                    // .imagePath() // 指定相机拍照的路径，建议非特殊情况不要指定.
                                    .start(ACTIVITY_CAMREA); // 666是请求码，返回时onActivityResult()的第一个参数。
                        } else if (i == 2) {
                            Album.album(getActivity())
                                    .toolBarColor(getResources().getColor(R.color.colorPrimaryDark)) // Toolbar 颜色，默认蓝色。
                                    .statusBarColor(getResources().getColor(R.color.colorPrimaryDark)) // StatusBar 颜色，默认蓝色。
                                    .navigationBarColor(getResources().getColor(R.color.colorPrimaryDark)) // NavigationBar 颜色，默认黑色，建议使用默认。
                                    .title("图库") // 配置title。
                                    .columnCount(3) // 相册展示列数，默认是2列。
                                    .selectCount(1)
                                    .camera(false) // 是否有拍照功能。
                                    .start(ACTIVITY_ALBUM); // 999是请求码，返回时onActivityResult()的第一个参数。
                        }else if(i==3){

                            ToStartActivity(VrActivity.class);
                        }
                    }
                });

                return inflate;
            }
        });*/


    }

    @Override
    public int setView() {
        return R.layout.catory_fagment;
    }


}
